package com.csy.rabbit.admin.controller;

import com.csy.rabbit.commit.exception.BusinessException;
import com.csy.rabbit.commit.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class BaseExceptionHandler {
	
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result<Object> error(Exception e){
        return Result.error("异常错误");
    }

    @ExceptionHandler(value = BusinessException.class)
    @ResponseBody
    public Result<Object> error(BusinessException e){
        return Result.error(e.getMessage());
    }
}